/**
 * 
 */
package info.niwota.webagent;

import info.niwota.gae.cache.PostServlet;
import info.niwota.org.json.JSONObject;
import info.niwota.webagent.peer.ChannelManager;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @author qiangli
 *
 */
@SuppressWarnings("serial")
public class ProxyPostServlet extends PostServlet {
	private static final Logger log = Logger.getLogger(ProxyPostServlet.class
			.getName());
	private static final ChannelManager manager = ChannelManager.getInstance();
	
	@Override
	protected void sendReply(HttpServletRequest req, HttpServletResponse resp,
			boolean success, String msg, JSONObject data) throws Exception {
		final String cid = data.getString("cid");
		
		log.finest("cid: " + cid);

		manager.dispatch(cid, data);
		//
		super.sendReply(req, resp, success, msg, data);
	}
}
